package com.mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mall.entity.SmsCouponHistory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SmsCouponHistoryMapper extends BaseMapper<SmsCouponHistory> {

    @Select("select * from sms_coupon_history where member_id = #{id}")
    List<SmsCouponHistory> getByMemberId(@Param("id") Long id);

    @Select("select * from sms_coupon_history where member_id = #{id} and coupon_id = #{id1}")
    SmsCouponHistory getByIds(@Param("id") Long id,@Param("id1") Long id1);

    @Select("select count(*) from sms_coupon_history where member_id=#{id} and coupon_id = #{id1}")
    Integer getCounts(@Param("id") Integer id,@Param("id1") Long id1);

    @Update("update sms_coupon_history set use_status = 1 where coupon_id = #{couponId} and member_id = #{memberId}")
    boolean setUsed(@Param("couponId") Long couponId,@Param("memberId") Long memberId);
}
